package com.wish.controller;


import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.wish.entity.*;
import com.wish.service.IPremisesInfoService;
import com.wish.service.IPrivateFacilityService;
import com.wish.service.IPublicFacilityService;
import com.wish.service.ISysUserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * <p>
 * 楼盘信息表 前端控制器
 * </p>
 *
 * @author 闫东浩
 * @since 2021-03-29
 */
@RestController
@RequestMapping("/premises-info")
public class PremisesInfoController {
    @Autowired
    private IPublicFacilityService publicFacilityService;
    @Autowired
    private IPrivateFacilityService privateFacilityService;
    @Autowired
    private ISysUserService sysUserService;
    @Autowired
    private IPremisesInfoService premisesInfoService;

    //公共配置
    @RequestMapping("getGg")
    public List<PublicFacility> getGg(){
       List<PublicFacility> getGgs = publicFacilityService.list();
       return getGgs;
    }
    //房间配置
    @RequestMapping("getFj")
    public List<PrivateFacility> getFj(){
        List<PrivateFacility> getFjs = privateFacilityService.list();
        return getFjs;
    }
    //获取管家
    @RequestMapping("getGj")
    public List<SysUser> getGj(){
        List<SysUser> getGjs = sysUserService.list();
        return getGjs;
    }
    //获取楼盘
    @RequestMapping("getLp")
    public Page<PremisesInfo> getLp(@RequestBody PremisesInfoVo premisesInfoVo){
        QueryWrapper<PremisesInfo> wrapper = new QueryWrapper<>();
        if(premisesInfoVo.getLname() != null && premisesInfoVo.getLname()!=""){
            wrapper.like("name",premisesInfoVo.getLname());
        }
        Page<PremisesInfo> page = new Page<>();
        page.setCurrent(premisesInfoVo.getPageNum());
        page.setSize(premisesInfoVo.getPageSize());
        Page<PremisesInfo> pageInfo = premisesInfoService.getList(wrapper,page);
        return pageInfo;
    }
}
